package east2west.service;

import east2west.dao.LocationDAO;
import east2west.dao.SchedulesDAO;
import east2west.dao.TourCancelDAO;
import east2west.dao.TourDAO;
import east2west.dao.TourDetailDAO;
import east2west.dao.TourOrderDAO;
import east2west.dao.TourOrderDetailDAO;
import east2west.dao.TourPriceDAO;
import east2west.dao.TourServiceDAO;
import east2west.dao.TourTypeDAO;
import east2west.dto.LocationDTO;
import east2west.dto.SaleTourDTO;
import east2west.dto.SchedulesLocationDTO;
import east2west.dto.SchedulesDTO;
import east2west.dto.TourCancelDTO;
import east2west.dto.TourDTO;
import east2west.dto.TourDetailDTO;
import east2west.dto.TourOrderDTO;
import east2west.dto.TourOrderDetailDTO;
import east2west.dto.TourPriceDTO;
import east2west.dto.TourServiceDTO;
import east2west.dto.TourTypeDTO;
import java.util.ArrayList;

/**
 *
 * @author Admin
 */
public class TourService {

    TourDAO tourDao = new TourDAO();
    TourTypeDAO typeDao = new TourTypeDAO();
    LocationDAO locationDao = new LocationDAO();
    TourPriceDAO tourPriceDao = new TourPriceDAO();
    TourOrderDetailDAO tourOrderDetailDao = new TourOrderDetailDAO();
    TourDetailDAO tourDetailDao = new TourDetailDAO();
    TourOrderDAO tourOrderDao = new TourOrderDAO();
    TourCancelDAO tourCancel = new TourCancelDAO();
    TourServiceDAO tourSerDAO = new TourServiceDAO();
    SchedulesDAO scheduleDAO = new SchedulesDAO();

    public ArrayList<TourDTO> readByAll() {
        try {
            return tourDao.readByAll();
        } catch (Exception exx) {
            return null;
        }
    }

    public ArrayList<TourDTO> readByAllDeparture() {
        return tourDao.readByAllDeparture();
    }

    public ArrayList<TourDTO> readByAllDestination() {
        return tourDao.readByAllDestination();
    }

    public ArrayList<TourTypeDTO> readByTourType() {
        return typeDao.readByAll();
    }

    public ArrayList<TourDTO> readByTopTour() {
        try {
            return tourDao.readByTopTour();
        } catch (Exception exx) {
            return null;
        }
    }

    public TourDTO findById(int id) {
        return tourDao.findById(id);
    }

    public ArrayList<SchedulesLocationDTO> showLocationTourName(int id) {
        return locationDao.showLocationTourName(id);
    }

    public float getMin(int id) {
        return tourPriceDao.getMin(id);
    }

    public float getMax(int id) {
        return tourPriceDao.getMax(id);
    }

    public ArrayList<TourPriceDTO> listavgPrice(int id) {
        return tourPriceDao.avgPrice(id);
    }

    public ArrayList<TourDTO> findByShowTourTop() {
        return tourDao.findByTourShowTop();
    }

    public ArrayList<TourDTO> findByTourShowTopMenu() {
        return tourDao.findByTourShowTopMenu();
    }

    public TourPriceDTO findByTourPriceId(int id) {
        return tourPriceDao.findById(id);
    }

    public TourOrderDetailDTO findByTourOrderDetail(int id) {
        return tourOrderDetailDao.findById(id);
    }

    public float getSumPriceTourDetail(int id) {
        return tourDetailDao.getSumPriceTourDetail(id);
    }

    public ArrayList getServiceName(int id) {
        return tourDetailDao.getSerViceName(id);
    }

    public int create(TourOrderDTO dto) {
        return tourOrderDao.create(dto);
    }

    public boolean create(TourOrderDetailDTO dto) {
        return tourOrderDetailDao.create(dto);
    }

    public ArrayList<TourDTO> findByOrtherTour(int id) {
        return tourDao.findByOrtherTour(id);
    }
    //Sale

    public float saleTourType(int id) {
        return tourDao.totalTypeName(id);
    }

    //tim kiem tourorder theo code
    public TourOrderDTO findByTourOrderId(int id) {
        return tourOrderDao.findById(id);
    }

    public ArrayList<TourOrderDetailDTO> findTourOrderDetailCancel(int tourOrderId) {
        return tourOrderDetailDao.findTourOrderDetailCancel(tourOrderId);
    }
    //tim kiem trong tour cancel tu orderdetailid

    public TourCancelDTO findByOrderDetail(int id) {
        return tourCancel.findByTourOrderDetailId(id);
    }

    public ArrayList<SaleTourDTO> listAllSaleTour() {
        return tourDao.listAll();
    }

    public ArrayList<SaleTourDTO> listFillter() {
        return tourDao.getListFillter();
    }

    public float totalDuration(int duration) {
        return tourDao.totaDuration(duration);
    }

    public float totalCost(float price1, float price2) {
        return tourDao.totalCost(price1, price2);
    }

    public ArrayList<TourServiceDTO> readByTourService() {
        return tourSerDAO.readByAl();
    }

    public int createTour(TourDTO dto) {
        return tourDao.create(dto);
    }

    public boolean createTourDetail(TourDetailDTO dto) {
        return tourDetailDao.create(dto);
    }

    public boolean createTourPrice(TourPriceDTO dto) {
        return tourPriceDao.create(dto);
    }

    public float totalSeason(int month1, int month2) {
        return tourDao.totalSeason(month1, month2);
    }

    public ArrayList<LocationDTO> readByAllLocation() {
        return locationDao.readByAll();
    }

    public boolean creatSchedule(SchedulesDTO dto) {
        return scheduleDAO.create(dto);
    }

    public boolean update(TourDTO dto) {
        return tourDao.update(dto);
    }

    public boolean update(TourPriceDTO dto) {
        return tourPriceDao.update(dto);
    }

    public ArrayList<SchedulesDTO> findScheduleByTourId(int tourId) {
        return scheduleDAO.findByTourId(tourId);
    }

    public boolean deleteSchedule(int scheduleId) {
        return scheduleDAO.delete(scheduleId);
    }

    public boolean update(SchedulesDTO dto) {
        return scheduleDAO.update(dto);
    }

    public boolean update(TourDetailDTO detailDTO) {
        return tourDetailDao.update(detailDTO);
    }

    public boolean deleteService(int detailId) {
        return tourDetailDao.delete(detailId);
    }

    public ArrayList<TourDTO> listSearch(TourDTO dto) {
        return tourDao.findByDto(dto);
    }

    public boolean create(TourCancelDTO cancelDTO) {
        return tourCancel.create(cancelDTO);
    }

    public TourPriceDTO getPriceIdTop(int id) {
        return tourPriceDao.getPirceIdTop(id);

    }

    public LocationDTO getLocaltionById(int id) {
        return locationDao.findById(id);
    }

    public boolean deleteTour(int id) {
        return tourDao.delete(id);
    }

    public ArrayList<TourOrderDTO> readOrder() {
        return tourOrderDao.readByAll();
    }

    public boolean acceptOrder(int id) {
        return tourOrderDao.acceptOrder(id);
    }

    public boolean deleteOrder(int id) {
        return tourOrderDao.delete(id);
    }
}
